﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace LL3D
{
    public class GameOver
    {
        //Imagem de fundo
        Texture2D BackGround; //Tela de fundo da tela inicial

        //Variaveis do cursor -----------------------------------------
        Texture2D cursor;
        Vector2 cursorPosition;  //Cursor que apontara as opcoes

        int option = 1;
        KeyboardState oldkeyState = Keyboard.GetState();
        //-------------------------------------------------------------
        
        public GameOver(ContentManager Content)
        {
            //Esse construtor serve para dar load das imagens relacionadas a tela game over
            BackGround = Content.Load<Texture2D>("GameOverMenu"); //Loading tela de fundo
            cursor = Content.Load<Texture2D>("Cursor"); //Loading cursor
        }

        public void Update()
        {
            KeyboardState keyState = Keyboard.GetState();

            //Rodara a opcao escolhida ao apertarmos ENTER
            if (keyState.IsKeyDown(Keys.Enter) && !oldkeyState.IsKeyDown(Keys.Enter))
            {
                if (option != 3 && option != 2) // Opcao start
                {
                    Game1.telaAtual = 2;

                }

                if (option != 3 && option != 1)  //Opcao instructions
                {
                    Game1.telaAtual = 3;
                }

                if (option != 1 && option != 2)   //Opcao exit
                {
                    Game1.telaAtual = 5;
                }
            }


            if (keyState.IsKeyDown(Keys.Down) && !oldkeyState.IsKeyDown(Keys.Down))
            {
                if (option != 3)
                {
                    option += 1; // Vai para a opção de baixo
                }
            }
            if (keyState.IsKeyDown(Keys.Up) && !oldkeyState.IsKeyDown(Keys.Up))
            {
                if (option != 1)
                {
                    option -= 1; // Vai para a opção de cima
                }
            }
            //Esse switch coloca o cursor nas posicoes das opcoes da tela de entrada
            //switch (option)
            //{
            //    case 1:
            //        cursorPosition = new Vector2(265, 395);
            //        break;
            //    case 2:
            //        cursorPosition = new Vector2(180, 435);
            //        break;
            //    case 3:
            //        cursorPosition = new Vector2(290, 475);
            //        break;
            //}
            //-----------------------------------------------------------------------

            oldkeyState = keyState;
        }

        public void Draw(SpriteBatch Spritebatch) // Draw da classe
        {
            Spritebatch.Begin();
            //Desenhando a tela inicial do jogo-----------------------------------------
            Spritebatch.Draw(BackGround, new Rectangle(0, 0, 800, 600), Color.White);
            //--------------------------------------------------------------------------
            //Desenhando o cursor----------------------------------------------------------------
            //Spritebatch.Draw(cursor, cursorPosition, new Rectangle(0, 0, 40, 40), Color.White);
            //-----------------------------------------------------------------------------------
            Spritebatch.End();
        }

    }
}
